package com.un.ebs.inventory.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.un.ebs.inventory.domain.*;
import com.un.ebs.inventory.dto.JxcVo;
import com.un.ebs.inventory.mapper.AccountMonthMapper;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author liubo
 * @since 2020-05-23
 */
public interface InventoryService {

    /**
     * 增加库存量
     *
     * @param itemId
     * @param warehouseId
     * @param skuId
     * @param qty
     */
//    void plus(String itemId, String warehouseId, String skuId, Double qty, boolean releaseLock);

    void plus(String itemId, String warehouseId, String skuId, Double qty, Double price, boolean releaseLock);


    /**
     * 减少库存量
     *
     * @param itemId
     * @param warehouseId
     * @param skuId
     * @param qty
     */
//    void reduce(String itemId, String warehouseId, String skuId, Double qty, boolean releaseLock);

    void reduce(String itemId, String warehouseId, String skuId, Double qty, Double price, boolean releaseLock);

    /**
     * 移动库存
     *
     * @param itemId
     * @param fromWarehouseId
     * @param toWarehouseId
     * @param skuId
     * @param qty
     */
    void move(String itemId, String fromWarehouseId, String toWarehouseId, String skuId, Double qty);

    /**
     * 锁定入库量
     *
     * @param itemId
     * @param warehouseId
     * @param skuId
     * @param qty
     */
    void lockByPlus(String itemId, String warehouseId, String skuId, Double qty);

    /**
     * 锁定出库量
     *
     * @param itemId
     * @param warehouseId
     * @param skuId
     * @param qty
     */
    void lockByReduce(String itemId, String warehouseId, String skuId, Double qty);

    void lockByMove(String itemId, String fromWarehouseId, String toWarehouseId, String skuId, Double qty);

    void lockReleaseByMove(String itemId, String fromWarehouseId, String toWarehouseId, String skuId, Double qty);

    void reset(String skuId);

    void updateAccount(int year, int month, boolean isRecountCostPrice);

    void updateAccount(int year, int month) throws SQLException;

    /**
     * 调整期末成本金额
     *
     * @param id
     * @param adjustMoney
     */
    void updateEndCostMoney(String id, Double adjustMoney, String remark);

    void updateEndCostMoneyClear(String id);

    Inventory queryById(String id);

    Inventory queryById(String warehouseId, String skuId);

    List<InventoryExt> queryBySku(String skuId);

    IPage<InventoryExt> query(String searchText, String classId, String warehouseId, Integer pageSize, Integer pageIndex);

    IPage<InventoryLogExt> queryLog(String skuId, String warehouseId, String noteCode, Integer pageSize, Integer pageIndex);

    double queryCostPrice(String skuId, int year, int month);

    double queryCostPrice(String skuId);

    void closeAccount(int year, int month);

    void closeCancelAccount(int year, int month);

    AccountMonth createAccountMonth(int year, int month);

    IPage<JxcVo> queryCurrentJxc(String skuCode, int pageSize, int pageIndex);

    IPage<InventoryJxcByWarehouse> queryJxcByWarehouse(int year, int month, int pageSize, int pageIndex);

    IPage<InventoryJxcBySku> queryJxcBySku(String skuCode, String warehouseId, int year, int month, int pageSize, int pageIndex);

    IPage<AccountMonth> queryAccountMonth(int pageSize, int pageIndex);

    AccountMonth queryAccountMonth(Date date);

    AccountMonth queryAccountMonthById(String accountId);

    IPage<InventoryAge> queryInventoryAge(int pageSize, int pageIndex);

    /**
     * 同步至财务系统（K3）
     *
     * @param accountId
     */
    void syncFinance(String accountId);

    void syncFinanceComplete(String accountId);
}
